package com.cosina.game.crystallight.ui.menu.transform;

import android.graphics.Canvas;

public class ClickRotateTransform extends Transform {

	@Override
	public void buttonClick() {
		this.clicked = true;
	}

	final int rotateSpeed = 5;
	public int rotate = 0;
	
	public static final int CLICK_ROTATE = -20;
	@Override
	public void doT(Canvas canvas) {
		if(this.rotate< 0){
			canvas.rotate(-this.rotate,this.occpuy.left,this.occpuy.top);
		}
	}

	@Override
	public void undoT(Canvas canvas) {
		if(this.rotate < 0){
			canvas.rotate(this.rotate,this.occpuy.left,this.occpuy.top);
		}
	}

	public boolean clicked = false;
	public boolean up = true;

	@Override
	public void update(){
		if(clicked == false){
			if(rotate <= 0)
				rotate += rotateSpeed;
		}else{
			if(up){
				rotate -= rotateSpeed;
			}else{
				rotate += rotateSpeed;
			}
			if(up){
				if(rotate <= CLICK_ROTATE){
					up = false;
				}
			}else{
				if(rotate >= 0){
					up = true;
					clicked = false;
				}
			}
		}
	}
}
